package com.lemon.smartsafety.ui.activity.safe.data.safe_manager;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.app.AppManager;
import com.lemon.smartsafety.app.BundleKey;
import com.lemon.smartsafety.entity.event.base.AppEvent;
import com.lemon.smartsafety.entity.safe.company.CompanyInfo;
import com.lemon.smartsafetynew.ui.activity.base.BaseFragmentActivity;
import com.lemon.smartsafety.ui.fragment.safe.safe_manager.SafeManagerListFragment;

import org.greenrobot.eventbus.Subscribe;

/**
 * Created by Cooliean on 16/3/20.
 * 安全管理设置一览
 */
public class SafeManagerListActivity extends BaseFragmentActivity {
    private CompanyInfo mCompanyInfo;


    @Override
    protected void getBundleArgs() {
        super.getBundleArgs();
        if (getIntent().getExtras() != null) {
            mCompanyInfo = (CompanyInfo) getIntent().getSerializableExtra(BundleKey.COMPANY_INFO);
        }
    }

    @Override
    public Fragment getFragment() {
        Bundle bundle = new Bundle();
        bundle.putSerializable(BundleKey.COMPANY_INFO, mCompanyInfo);
        Fragment fragment = SafeManagerListFragment.newInstance();
        fragment.setArguments(bundle);
        return fragment;
    }


    @Subscribe
    public void onEventMainThread(AppEvent event) {
    }


    @Override
    protected void initTitle() {
        this.setBarTitle(R.string.safe_manager_list);
    }




    @Override
    protected void callFinish() {
        AppManager.getAppManager().finishActivity(SafeManagerListActivity.class);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            callFinish();
        }
        return super.onKeyDown(keyCode, event);
    }
}
